/**
 * Created by Administrator on 2017/5/15.
 */
//聊天内容滚动条
var myScroll;
function loaded () {
    myScroll = new IScroll('#wrapper', {
        bounceEasing: 'elastic',
        bounceTime: 1200,
    });
    myScroll.scrollToElement('.news:last-child', 100);
}
//document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
var test = document.getElementById("test");
var div = document.getElementById("divmsg");
div.scrollTop = div.scrollHeight;
test.onclick = function () {
    div.innerHTML = div.innerHTML+"<div class='news'><div class='fl headImg'><img src='src/imgs/defaltFace.jpg'/></div><div class='fl sendNews'><p class='name'>哈哈哈</p><p class='newCon'>新消息</p></div></div>";
    boxScroll(div);
    myScroll.refresh();//增加内容后重置iscroll，重新计算iscroll高度
    myScroll.scrollToElement('.news:last-child', 100);//控制iscroll滚动到消息最新一条
}
function boxScroll(o){
    o.scrollTop = o.scrollHeight;
}


//点击input屏幕上滑
$(document).ready(function(){
    $('.inputTxt').bind('focus',function(e){
        var $this = $(this);
        e.preventDefault();
        setTimeout(function(){
            $(window).scrollTop($this.offset().top - 60);
        },500)
    });
    $(document).on('resize',function(){
        $('.inputTxt').each(function(index,dom){
            if($(dom).is(':focus')){
                $(window).scrollTop($this.offset().top - 60);
            }
        });
    });
});

//点击语音出现对应内容
$(function(){
    $(".content,.conList").hide();
    /*$(".audios ul li:first").addClass("current");*/
    $(".audios ul li").click(function(){
        $(this).find("i").removeClass("chart").addClass("chart2");
        $(this).siblings("li").find("i").removeClass("chart2").addClass("chart");
        $(this).addClass("current").siblings().removeClass("current");
        var index=$(this).index();
        $(".content").show();
        $(".content .conList").eq(index).show().siblings().hide();
    })
});

//点击语音屏幕上滑
$(document).ready(function($){
    //屏幕上滑及隐藏语音
    $('.msgList').click(function(){
        $('html,body').animate({
            scrollTop: '0px'
        }, 300);
        //延迟3ms后执行隐藏语音
        setTimeout(function(){
            $(".content,.conList").hide();
        },300);
    });
    //屏幕下滑
    $('.audios ul li').click(function(){
        $('html,body').animate({
            scrollTop:$('.content').offset().top
        }, 400);
    });
});
